<template>
  <cfg-form :ref="ref" v-bind="attrs" :data="data.values"></cfg-form>
</template>

<script>
import { typeClassName } from "@/pages/config/classNameMap";
export default {
  name: "pg-form",
  components: {},
  inject: ["anc"],
  data() {
    return {
      ref: "editView",
      onlyRead: false,
      loading: false,
      
    };
  },
  props: {
    data: {
      default: () => {
        return {};
      },
    },
  },
  watch: {},
  computed: {
   attrs() {
      return {
        labelWidth: 100,
        labelPosition: "right",
        cols: 2,
        columns: [
        {
          key: "sf_code",
          title:  "参数编码",
          minWidth: 100,
          align: "center",
          config: { type: "text" },
        },
        {
          key: "sf_name",
          title:  "参数名称",
          minWidth: 100,
          align: "center",
          config: { type: "text" },
        },
        {
          key: "status",
          title:  "状态",
          minWidth: 100,
          align: "center",
          config: { type: "select", options: this.anc.statusOptions },
        },
        {
          key: "unit",
          title:  "参数单位",
          minWidth: 100,
          align: "center",
          config: { type: "text" },
        },
        {
          key: "itemType",
          title:  "参数类型",
          minWidth: 100,
          align: "center",
          config: { type: "select", options: this.anc.paramTypeOptions },
        },
        {
          key: "standard",
          title:  "标准值",
          minWidth: 100,
          align: "center",
          config: { type: "text", disabled: false },
        },
        {
          key: "min",
          title:  "区间最小值",
          minWidth: 100,
          align: "center",
          config: { type: "text", disabled: false },
        },
        {
          key: "max",
          title:  "区间最大值",
          minWidth: 100,
          align: "center",
          config: { type: "text", disabled: false },
        },
        {
          key: "remark",
          title:  "备注",
          minWidth: 100,
          align: "center",
          config: { type: "textarea" },
        },
        ],
        rules: {
          sf_code: [
            { required: true, message: "不能为空", trigger: "blur" },
          ],
          sf_name: [
            { required: true, message: "不能为空", trigger: "blur" },
          ],
        },
        // onlyRead: this.onlyRead,
      };
    },
  },
  created() {},
  mounted() {
    this.$nextTick(() => {
      this.$set(this.anc.vms, this.ref, this);
      this.jobClassObject = this.$modelObject.create(
        `${typeClassName["job"].modelType}`
      );
      this.positionClassObject = this.$modelObject.create(
        `${typeClassName["position"].modelType}`
      );
      this.anc.setOptionsByHier(
        "job",
        this.jobClassObject,
        "jobOptions",
        {
          label: "sf_name",
          value: "sf_code",
        },
        "editView"
      );
      this.anc.setOptionsByHier(
        "position",
        this.positionClassObject,
        "positionOptions",
        {
          label: "sf_name",
          value: "sf_code",
        },
        "editView"
      );
    });
  },
  methods: {
    validate(fn) {
      return this.$refs[this.ref].$refs["form"].validate((valid) => {
        if (fn) {
          return fn(valid);
        } else {
          return valid;
        }
      });
    },
    resetFields() {
      this.$refs[this.ref].$refs["form"].resetFields();
    },
  },
};
</script>
<style scoped></style>
